package com.keggview.application.views;

import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;

import com.keggview.application.datatypes.Registry;
import com.keggview.application.treeviewer.ui.TreeViewContentProvider;
import com.keggview.application.treeviewer.ui.TreeViewLabelProvider;

public class ElementsTreeView extends ViewPart {

	public static final String ID = "com.keggview.application.views.TreeView";
	
	private Composite parent;

	/** widok drzewa */
	private static TreeViewer viewer;
	
//	private static ListViewer listViewer;
	
//	/** display */
//	private Display display;
	
	/** korzen wyswietlanego drzewa */
//	private static TreeParent root;
	
	public ElementsTreeView() {

//		display = PlatformUI.getWorkbench().getDisplay();
	}

	@Override
	public void createPartControl(Composite parent2) {
		this.parent = parent2;

		// create tree view
		viewer = new TreeViewer(this.parent, SWT.MULTI | SWT.H_SCROLL
				| SWT.V_SCROLL | SWT.BORDER);
		// create content provider
		viewer.setContentProvider(new TreeViewContentProvider());
		viewer.setLabelProvider(new TreeViewLabelProvider());
		if (Registry.pathways.size() > 0) {
			viewer.setInput(Registry.pathways.get(0));
		}
		viewer.expandAll();
		getSite().setSelectionProvider(viewer);
		
		
//		listViewer = new ListViewer(parent, SWT.SINGLE );		

		
//		Group grp1 = new Group (parent,SWT.NONE);
//		grp1.setText("Preview");
//		RowLayout rowLayout = new RowLayout();
//		grp1.setLayout(rowLayout);
//
//		Button btn = new Button(grp1,SWT.PUSH);
//		btn.setText("Hello");
//		
//		// fill in the element
//		AdaptableList ctlList = new AdaptableList();
//		ButtonElement btnEl = new ButtonElement(btn,"Button");
//		ctlList.add(btnEl);
		
//		listViewer.setContentProvider(new WorkbenchContentProvider());
//		listViewer.setLabelProvider(new WorkbenchLabelProvider());			
//		listViewer.setInput(ctlList);
//		getSite().setSelectionProvider(listViewer);
	}

	@Override
	public void setFocus() {
		
//		listViewer.getControl().setFocus();
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public Object getAdapter(Class adapter) {
		// TODO Auto-generated method stub
		return super.getAdapter(adapter);
	}
	
	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		super.dispose();
	}
}
